import usb.core
import usb.util

class USBManager:
    def find_devices(self, vendor_id: int, product_id: int) -> List:
        """查找设备"""
        return usb.core.find(idVendor=vendor_id, idProduct=product_id, find_all=True)

    def claim_device(self, dev):
        """声明设备"""
        if dev.is_kernel_driver_active(0):
            dev.detach_kernel_driver(0)
        usb.util.claim_interface(dev, 0)